******************************************************************************
*                                                                            *
* Alexander B. Downes and Todd S. Sechser                                    *
* "The Illusion of Democratic Credibility"                                   *
* International Organization 66:3 (2012): 457-81                             *
*                                                                            *
******************************************************************************


* Purpose
* This is a Stata replication file for "The Illusion of Democratic Credibility."  This file replicates the regressions and charts which use the Militarized Compellent Threats dataset (pp. 474-83), and which are reported in the document "Downes-Sechser-Appendices.pdf".
*
* Location
* Replication data and this command file can be downloaded from <http://dvn.iq.harvard.edu/dvn/dv/tsechser>.
* 
* Requirements
* 1. This file requires the "ldfbeta" Stata package.  It can be installed by typing "net install ldfbeta, from(http://www.ats.ucla.edu/stat/stata/ado/analysis)" (without quotes) into the Stata command window.  The original article used Intercooled Stata 10.1.
* 2. This file also requires the "estout" Stata package.  It can be installed by typing "ssc install estout" (without quotes) into the Stata command window, or by visiting <http://repec.org/bocode/e/estout/installation.html>.
* 3. The charts at the end of the file require the "Clarify" Stata package.  It can be installed by typing "net install clarify, from(http://gking.harvard.edu/clarify)" (without quotes) into the Stata command window, or by visiting <http://gking.harvard.edu/clarify>.
* 4. This file requires the Stata dataset "Downes-Sechser-Appendix-C.dta", which can be downloaded from <http://dvn.iq.harvard.edu/dvn/dv/tsechser>.
*
* Other Notes
* 1. Table numbers refer to tables in Appendix C unless otherwise noted.
*
* Version
* Last updated: August 20, 2012



* Profile of Schultz's original models (Schultz 2001, pp. 146-47)
*
* Model 1: all crises, World War years included, robust standard errors clustered on crisis
* Model 2: all crises, World War years excluded, robust standard errors clustered on crisis
* Model 3: bilateral crises only, World War years included
* Model 4: bilateral crises only, World War years excluded


clear
set more off
di "How much memory would you like to allocate to Stata? " _request(mem)
set mem $mem
*Set directory
di "Please type the pathway for the folder containing the datasets to be merged: " _request(dir)
cd $dir

use Downes-Sechser-Appendix-C.dta

***Table 5 (also Table 4 in "The Illusion of Democratic Credibility" [p. 478])

*Model 1
eststo M1: logit failure_100_ks democ_a_ks democ_b_ks demdem_ks majmaj_ks majmin_ks minmaj_ks capshare_a_ks contig_ks swt_dyad tau_lead_a tau_lead_b territory_ks government_ks policy_ks other_ks dummy1914_ks dummy1915_ks dummy1916_ks dummy1917_ks dummy1918_ks dummy1939_ks dummy1940_ks dummy1941_ks dummy1942_ks dummy1943_ks dummy1945_ks, robust cluster(mct_code) 

*Model 2
eststo M2: logit failure_100_ks democ_a_ks democ_b_ks demdem_ks majmaj_ks majmin_ks minmaj_ks capshare_a_ks contig_ks swt_dyad tau_lead_a tau_lead_b  territory_ks government_ks policy_ks other_ks if worldwar_ks==0, robust cluster(mct_code)

*Model 3
eststo M3: logit failure_100_ks democ_a_ks democ_b_ks demdem_ks majmaj_ks majmin_ks minmaj_ks capshare_a_ks contig_ks swt_dyad tau_lead_a tau_lead_b   territory_ks government_ks policy_ks other_ks dummy1914_ks dummy1915_ks dummy1916_ks dummy1917_ks dummy1918_ks dummy1939_ks dummy1940_ks dummy1941_ks dummy1942_ks dummy1943_ks dummy1945_ks if bilateral_ks == 1

*Model 4
eststo M4: logit failure_100_ks democ_a_ks democ_b_ks demdem_ks majmaj_ks majmin_ks minmaj_ks capshare_a_ks contig_ks swt_dyad tau_lead_a tau_lead_b   territory_ks government_ks policy_ks other_ks if worldwar_ks==0 & bilateral_ks == 1

esttab M1 M2 M3 M4, drop(dummy19*ks) se(2) pr2 b(2) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) label varwidth(50)


***Table 6

*Model 5
eststo M5: logit failure_100_ks democpolity_a_ks democpolity_b_ks demdempolity_ks majmaj_ks majmin_ks minmaj_ks capshare_a_ks contig_ks swt_dyad tau_lead_a tau_lead_b territory_ks government_ks policy_ks other_ks dummy1914_ks dummy1915_ks dummy1916_ks dummy1917_ks dummy1918_ks dummy1939_ks dummy1940_ks dummy1941_ks dummy1942_ks dummy1943_ks dummy1945_ks, robust cluster(mct_code) 

*Model 6
eststo M6: logit failure_100_ks democpolity_a_ks democpolity_b_ks demdempolity_ks majmaj_ks majmin_ks minmaj_ks capshare_a_ks contig_ks swt_dyad tau_lead_a tau_lead_b  territory_ks government_ks policy_ks other_ks if worldwar_ks==0, robust cluster(mct_code)

*Model 7
eststo M7: logit failure_100_ks democpolity_a_ks democpolity_b_ks demdempolity_ks majmaj_ks majmin_ks minmaj_ks capshare_a_ks contig_ks swt_dyad tau_lead_a tau_lead_b   territory_ks government_ks policy_ks other_ks dummy1914_ks dummy1915_ks dummy1916_ks dummy1917_ks dummy1918_ks dummy1939_ks dummy1940_ks dummy1941_ks dummy1942_ks dummy1943_ks dummy1945_ks if bilateral_ks == 1

*Model 8
eststo M8: logit failure_100_ks democpolity_a_ks democpolity_b_ks demdempolity_ks majmaj_ks majmin_ks minmaj_ks capshare_a_ks contig_ks swt_dyad tau_lead_a tau_lead_b   territory_ks government_ks policy_ks other_ks if worldwar_ks==0 & bilateral_ks == 1

esttab M5 M6 M7 M8, drop(dummy19*ks) se(2) pr2 b(2) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) label varwidth(50)


***Table 7

*Model 9
eststo M9: logit failure_100_ks democ_cheibub_a democ_cheibub_b demdem_cheibub majmaj_ks majmin_ks minmaj_ks capshare_a_ks contig_ks swt_dyad tau_lead_a tau_lead_b territory_ks government_ks policy_ks other_ks dummy1914_ks dummy1915_ks dummy1916_ks dummy1917_ks dummy1918_ks dummy1939_ks dummy1940_ks dummy1941_ks dummy1942_ks dummy1943_ks dummy1945_ks, robust cluster(mct_code) 

*Model 10
eststo M10: logit failure_100_ks democ_cheibub_a democ_cheibub_b demdem_cheibub majmaj_ks majmin_ks minmaj_ks capshare_a_ks contig_ks swt_dyad tau_lead_a tau_lead_b   territory_ks government_ks policy_ks other_ks dummy1914_ks dummy1915_ks dummy1916_ks dummy1917_ks dummy1918_ks dummy1939_ks dummy1940_ks dummy1941_ks dummy1942_ks dummy1943_ks dummy1945_ks if bilateral_ks == 1

esttab M9 M10, se(2) pr2 b(2) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) label varwidth(50)


***Table 8

*Model 11
eststo M11: logit failure_100_ks democ_przeworski_a democ_przeworski_b demdem_przeworski majmaj_ks majmin_ks minmaj_ks capshare_a_ks contig_ks swt_dyad tau_lead_a tau_lead_b territory_ks government_ks policy_ks other_ks dummy1914_ks dummy1915_ks dummy1916_ks dummy1917_ks dummy1918_ks dummy1939_ks dummy1940_ks dummy1941_ks dummy1942_ks dummy1943_ks dummy1945_ks, robust cluster(mct_code) 

*Model 12
eststo M12: logit failure_100_ks democ_przeworski_a democ_przeworski_b demdem_przeworski majmaj_ks majmin_ks minmaj_ks capshare_a_ks contig_ks swt_dyad tau_lead_a tau_lead_b   territory_ks government_ks policy_ks other_ks dummy1914_ks dummy1915_ks dummy1916_ks dummy1917_ks dummy1918_ks dummy1939_ks dummy1940_ks dummy1941_ks dummy1942_ks dummy1943_ks dummy1945_ks if bilateral_ks == 1

esttab M11 M12, se(2) pr2 b(2) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) label varwidth(50)


***Table 9

*Model 13
eststo M13: logit failure_100_ks democ_boix_a democ_boix_b demdem_boix majmaj_ks majmin_ks minmaj_ks capshare_a_ks contig_ks swt_dyad tau_lead_a tau_lead_b territory_ks government_ks policy_ks other_ks dummy1914_ks dummy1915_ks dummy1916_ks dummy1917_ks dummy1918_ks dummy1939_ks dummy1940_ks dummy1941_ks dummy1942_ks dummy1943_ks dummy1945_ks, robust cluster(mct_code) 

*Model 14
eststo M14: logit failure_100_ks democ_boix_a democ_boix_b demdem_boix majmaj_ks majmin_ks minmaj_ks capshare_a_ks contig_ks swt_dyad tau_lead_a tau_lead_b  territory_ks government_ks policy_ks other_ks if worldwar_ks==0, robust cluster(mct_code)

*Model 15
eststo M15: logit failure_100_ks democ_boix_a democ_boix_b demdem_boix majmaj_ks majmin_ks minmaj_ks capshare_a_ks contig_ks swt_dyad tau_lead_a tau_lead_b   territory_ks government_ks policy_ks other_ks dummy1914_ks dummy1915_ks dummy1916_ks dummy1917_ks dummy1918_ks dummy1939_ks dummy1940_ks dummy1941_ks dummy1942_ks dummy1943_ks dummy1945_ks if bilateral_ks == 1

*Model 16
eststo M16: logit failure_100_ks democ_boix_a democ_boix_b demdem_boix majmaj_ks majmin_ks minmaj_ks capshare_a_ks contig_ks swt_dyad tau_lead_a tau_lead_b   territory_ks government_ks policy_ks other_ks if worldwar_ks==0 & bilateral_ks == 1

esttab M13 M14 M15 M16, drop(dummy19*ks) se(2) pr2 b(2) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) label varwidth(50)


***Table 10

*Model 17 (also Model 3 in Table 5 in "The Illusion of Democratic Credibility" [p. 480])
eststo M17: oprobit success_gg democ_a_gg democ_b_gg demdem_gg relaudcosts_gg audcostxresolve_gg capxdemdem_gg capshare_a_gg resolve_a_gg alliance_gg capxalliance_gg nukes_a_gg nukes_b_gg , robust cluster(mct_code)

*Model 18
eststo M18: oprobit success_gg democ_vanhanen_a democ_vanhanen_b demdem_vanhanen relaudcosts_vanhanen audcostxresolve_vanhanen capxdemdem_vanhanen capshare_a_gg resolve_a_gg alliance_gg capxalliance_gg nukes_a_gg nukes_b_gg, robust cluster(mct_code)

*Model 19
eststo M19: oprobit success_gg democ_unified_a democ_unified_b demdem_unified relaudcosts_unified audcostxresolve_unified capxdemdem_unified capshare_a_gg resolve_a_gg alliance_gg capxalliance_gg nukes_a_gg nukes_b_gg, robust cluster(mct_code)

esttab M17 M18 M19, se(4) pr2 b(4) star(+ 0.20 * 0.10 ** 0.02) label varwidth(70)

drop _est*


***Figure 1B (also Figure 1B in "The Illusion of Democratic Credibility" [p. 482])

quietly oprobit success_gg democ_a_gg democ_b_gg audcostxresolve_gg capxdemdem_gg capxalliance_gg capshare_a_gg resolve_a_gg nukes_a_gg nukes_b_gg demdem_gg relaudcosts_gg alliance_gg, robust cluster(mct_code)

sum capshare_a_gg if e(sample)
local capsharemean = r(mean)

estsimp oprobit success_gg democ_a_gg democ_b_gg audcostxresolve_gg capxdemdem_gg capxalliance_gg capshare_a_gg resolve_a_gg nukes_a_gg nukes_b_gg demdem_gg relaudcosts_gg alliance_gg, robust cluster(mct_code) sims(81000) genname(_b) antisim

gen cilow = .
gen cihi = .
gen predprob = .
gen polityaxis = .

local polity = 1
while `polity' <= 21 {
replace polityaxis = `polity' if _n <= `polity'*4000 & _n > (`polity'-1)*4000
local polity = `polity' + 0.25
}

local polity = 1
while `polity' <= 21 {
di "Value of polity: `polity'"
local audcostsq= (`polity'-1)^2
setx democ_a_gg `polity' democ_b_gg 1 audcostxresolve_gg `audcostsq'*2 capxdemdem_gg `polity'*1*`capsharemean' capxalliance_gg 0 capshare_a_gg `capsharemean' resolve_a_gg 2 nukes_a_gg 0 nukes_b_gg 0 demdem_gg `polity'*1 relaudcosts_gg `audcostsq' alliance_gg 0  
simqi, prval(2) genpr(prwin_gg_temp)
_pctile prwin_gg_temp, p(5,95)
replace cilow = r(r1) if polityaxis<`polity' + 0.01 & polityaxis > `polity'-0.01
replace cihi = r(r2) if polityaxis<`polity' + 0.01 & polityaxis > `polity'-0.01
sum prwin_gg_temp
replace predprob = r(mean) if polityaxis<`polity' + 0.01 & polityaxis > `polity'-0.01
drop prwin_gg_temp
local polity = `polity' + 0.2500
}

gen random = uniform()
twoway (rarea cilow cihi polityaxis, fcolor(gs12)) (line predprob polityaxis, lpattern(solid) lcolor(white)) if random <=0.1, legend(off) yscale(range(0 1)) xscale(range(1 21)) xlabel(1 5 9 13 17 21) xtitle("Challenger's Democracy Score") xtick(1 5 9 13 17 21) ylabel(.2 "20%" .4 "40%" .6 "60%" .8 "80%" 1 "100%", nogrid) ytitle("Probability of Compellent Threat Success") ytick(.2 .4 .6 .8 1)

drop cilow cihi polityaxis random _b* predprob
drop if mct_code == ""


***Figure 1C

quietly oprobit success_gg democ_vanhanen_a democ_vanhanen_b audcostxresolve_vanhanen capxdemdem_vanhanen capxalliance_gg capshare_a_gg resolve_a_gg nukes_a_gg nukes_b_gg demdem_vanhanen relaudcosts_vanhanen alliance_gg, robust cluster(mct_code)

sum capshare_a_gg if e(sample)
local capsharemean = r(mean)

estsimp oprobit success_gg democ_vanhanen_a democ_vanhanen_b audcostxresolve_vanhanen capxdemdem_vanhanen capxalliance_gg capshare_a_gg resolve_a_gg nukes_a_gg nukes_b_gg demdem_vanhanen relaudcosts_vanhanen alliance_gg, robust cluster(mct_code) sims(81000) genname(_b) antisim

gen cilow = .
gen cihi = .
gen predprob = .
gen polityaxis = .

local polity = 1
while `polity' <= 21 {
replace polityaxis = `polity' if _n <= `polity'*4000 & _n > (`polity'-1)*4000
local polity = `polity' + 0.25
}

local polity = 1
while `polity' <= 21 {
di "Value of polity: `polity'"
local audcostsq= (`polity'-1)^2
setx democ_vanhanen_a `polity' democ_vanhanen_b 1 audcostxresolve_vanhanen `audcostsq'*2 capxdemdem_vanhanen `polity'*1*`capsharemean' capxalliance_gg 0 capshare_a_gg `capsharemean' resolve_a_gg 2 nukes_a_gg 0 nukes_b_gg 0 demdem_vanhanen `polity'*1 relaudcosts_vanhanen `audcostsq' alliance_gg 0  
simqi, prval(2) genpr(prwin_gg_temp)
_pctile prwin_gg_temp, p(5,95)
replace cilow = r(r1) if polityaxis<`polity' + 0.01 & polityaxis > `polity'-0.01
replace cihi = r(r2) if polityaxis<`polity' + 0.01 & polityaxis > `polity'-0.01
sum prwin_gg_temp
replace predprob = r(mean) if polityaxis<`polity' + 0.01 & polityaxis > `polity'-0.01
drop prwin_gg_temp
local polity = `polity' + 0.2500
}

gen random = uniform()
twoway (rarea cilow cihi polityaxis, fcolor(gs12)) (line predprob polityaxis, lpattern(solid) lcolor(white)) if random <=0.1, legend(off) yscale(range(0 1)) xscale(range(1 21)) xlabel(1 5 9 13 17 21) xtitle("Challenger's Democracy Score") xtick(1 5 9 13 17 21) ylabel(.2 "20%" .4 "40%" .6 "60%" .8 "80%" 1 "100%", nogrid) ytitle("Probability of Compellent Threat Success") ytick(.2 .4 .6 .8 1)

drop cilow cihi polityaxis random _b* predprob
drop if mct_code == ""


***Figure 1D

quietly oprobit success_gg democ_unified_a democ_unified_b audcostxresolve_unified capxdemdem_unified capxalliance_gg capshare_a_gg resolve_a_gg nukes_a_gg nukes_b_gg demdem_unified relaudcosts_unified alliance_gg, robust cluster(mct_code)

sum capshare_a_gg if e(sample)
local capsharemean = r(mean)

estsimp oprobit success_gg democ_unified_a democ_unified_b audcostxresolve_unified capxdemdem_unified capxalliance_gg capshare_a_gg resolve_a_gg nukes_a_gg nukes_b_gg demdem_unified relaudcosts_unified alliance_gg, robust cluster(mct_code) sims(81000) genname(_b) antisim

gen cilow = .
gen cihi = .
gen predprob = .
gen polityaxis = .

local polity = 1
while `polity' <= 21 {
replace polityaxis = `polity' if _n <= `polity'*4000 & _n > (`polity'-1)*4000
local polity = `polity' + 0.25
}

local polity = 1
while `polity' <= 21 {
di "Value of polity: `polity'"
local audcostsq= (`polity'-1)^2
setx democ_unified_a `polity' democ_unified_b 1 audcostxresolve_unified `audcostsq'*2 capxdemdem_unified `polity'*1*`capsharemean' capxalliance_gg 0 capshare_a_gg `capsharemean' resolve_a_gg 2 nukes_a_gg 0 nukes_b_gg 0 demdem_unified `polity'*1 relaudcosts_unified `audcostsq' alliance_gg 0  
simqi, prval(2) genpr(prwin_gg_temp)
_pctile prwin_gg_temp, p(5,95)
replace cilow = r(r1) if polityaxis<`polity' + 0.01 & polityaxis > `polity'-0.01
replace cihi = r(r2) if polityaxis<`polity' + 0.01 & polityaxis > `polity'-0.01
sum prwin_gg_temp
replace predprob = r(mean) if polityaxis<`polity' + 0.01 & polityaxis > `polity'-0.01
drop prwin_gg_temp
local polity = `polity' + 0.2500
}

gen random = uniform()
twoway (rarea cilow cihi polityaxis, fcolor(gs12)) (line predprob polityaxis, lpattern(solid) lcolor(white)) if random <=0.1, legend(off) yscale(range(0 1)) xscale(range(1 21)) xlabel(1 5 9 13 17 21) xtitle("Challenger's Democracy Score") xtick(1 5 9 13 17 21) ylabel(.2 "20%" .4 "40%" .6 "60%" .8 "80%" 1 "100%", nogrid) ytitle("Probability of Compellent Threat Success") ytick(.2 .4 .6 .8 1)

drop cilow cihi polityaxis random _b* predprob
drop if mct_code == ""
